<form class="form-horizontal" method="post">
	
	<input type="hidden" name="action" value="modify_article" />
	<input type="hidden" name="idx" value="<?php echo $result['idx']?>" />

	<div class="control-group">
		<label class="control-label" for="select_board">Board</label>
		<div class="controls">
			<select name="board_id" id="select_board">
<?php foreach ($board as $k => $v) : ?>
				<option value="<?php echo $k?>"<?php echo ($result['board_id']==$k)?" selected":""?>><?php echo $v?></option>
<?php endforeach; ?>				
			</select>
		</div>
	</div>
<?php if (isset($category)) : ?>	
	<div class="control-group">
		<label class="control-label" for="select_category">Category</label>
		<div class="controls">
			<select name="category_idx" id="select_category">
<?php foreach ($category as $k => $v) : ?>
				<option value="<?php echo $k?>"<?php echo ($result['category_idx']==$k)?" selected":""?>><?php echo $v?></option>
<?php endforeach; ?>				
			</select>
		</div>
	</div>
<?php endif; ?>
	<div class="control-group">
		<label class="control-label" for="writer">Writer</label>
		<div class="controls">
			<input type="text" name="writer" id="writer" required="1" autofocus="1" value="<?php echo $result['writer']?>" />
		</div>
	</div>

	<div class="control-group">
		<label class="control-label" for="subject">Subject</label>
		<div class="controls">
			<input type="text" name="subject" id="subject" required="1" value="<?php echo $result['subject']?>" />
		</div>
	</div>
	
<?php if ( isset($result['options']) && $result['options'] != "" ) : ?>
<?php foreach($result['options'] as $k => $v) : ?>
	<div class="control-group">
		<label class="control-label" for="subject"><?php echo $k?></label>
		<div class="controls"><span class="help-block"><?php echo htmlspecialchars($v) ?></span></div>
	</div>
<?php endforeach; ?>
<?php endif; ?>

<?php if ( isset($result['files']) && $result['files'] != "" ) : ?>
<?php foreach($result['files'] as $k => $v) : ?>
	<div class="control-group">
		<label class="control-label" for="subject"><?php echo $k?></label>
		<div class="controls">
<?php foreach($v as $kk => $vv) : ?>
			<img src="http://<?php echo HOME?>/files/<?php echo $vv?>" alt="<?php echo $kk?>" style="width:300px;" />
<?php endforeach; ?>
		</div>
	</div>
<?php endforeach; ?>
<?php endif; ?>

	<div class="control-textarea">
		<textarea name="contents" id="contents" class="redactor" data-imageup="http://<?php echo HOME?>/redactor/image" data-fileup="http://<?php echo HOME?>/redactor/file"><?php echo htmlspecialchars($result['contents']) ?></textarea>
	</div>

<?php if ( isset($result['comment']) && $result['comment'] != "" && count($result['comment']) > 0) : ?>
	<table class="table table-striped table-condensed table-hover">
		<thead>
			<tr>
				<th class="">내용</th>
				<th style="width:70px">글쓴이</th>
				<th style="width:100px">등록일</th>
			</tr>
		</thead>
		<tbody>
	
<?php foreach($result['comment'] as $k => $v) : ?>
			<tr data-href="<?php echo $href?>/<?php echo $kong->id ?>/comment/<?php echo urlencode($v['idx'])?>">
				<td class="align-left"><?php echo nl2br($v['contents'])?></td>
				<td><?php echo $v['writer']?></td>
				<td><?php echo date("Y/m/d", $v['reg_date'])?></td>
			</tr>
<?php endforeach; ?>
	
		</tbody>
	</table>
<?php endif; ?>

	<div class="control-group">
		<div class="controls pull-right">
			<button type="submit" name="submit" id="submit" class="btn btn-warning">수정하기</button>
			<a data-toggle="modal" href="#myDelete" class="btn">삭제</a>
		</div>
	</div>

</form>




<form class="form-horizontal" method="post">
	<input type="hidden" name="action" value="delete_article" />
	<input type="hidden" name="idx" value="<?php echo $result['idx']?>" />
	
	<div id="myDelete" class="modal hide fade">
		<div class="modal-header">
			<button type="button" data-dismiss="modal" class="close">&times;</button>
			<h4>정말로 삭제합니까?</h4>
		</div>
		<div class="modal-body"><p>한번 삭제하면 다시는 돌이킬 수 없습니다.</p></div>
		<div class="modal-footer">
			<a href="#" data-dismiss="modal" class="btn">닫기</a>
			<button type="submit" class="btn btn-warning">삭제</button>
		</div>
	</div>
</form>

<script>
var category = <?php echo json_encode($category); ?>;
</script>



